package com.github.baichuan.web.ui.select;

import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

/**
 * 选项分组
 */
@Getter
public class OptionGroup {
    private String label;

    private OptionItem[] options;

    private OptionGroup(String label, OptionItem[] options) {
        this.label = label;
        this.options = options;
    }

    public static OptionGroup of(String label, OptionItem[] options) {
        if(StringUtils.isBlank(label)) {
            throw new IllegalArgumentException("label is blank");
        }
        if(options == null || options.length == 0) {
            throw new IllegalArgumentException("options is null or empty");
        }

        return new OptionGroup(label, options);
    }
}
